import csv


def data_aggregation(pca_result_devided):
    keypoints=[]
    for pca in pca_result_devided:
        no=len(pca)
        keypoint=[0 for i in range(53)]
        for pp in pca:
            for i in range(53):
                keypoint[i]+=pp[i]
        keypoint= [i/no for i in keypoint]
        keypoints.append(keypoint)
    # write_result(keypoints)
    return keypoints

def read_csv_plus(csv_name):
    f = open(csv_name, 'r')
    reader = csv.reader(f)
    result = []
    for row in reader:
        res=[]
        for re in row:
            re=re[1:-1].split(', ')
            re= [float(s) for s in re]
            res.append(re)
        result.append(res)
    return result

def write_result(result):
    f = open('data_aggregation_example.csv', 'w', encoding='utf-8', newline='')
    csv_writer = csv.writer(f)
    for res in result:
        csv_writer.writerow(res)
    f.close()

def read_csv(csv_name):
    f = open(csv_name, 'r')
    reader = csv.reader(f)
    result = []
    for row in reader:
        row = [float(s) for s in row]
        result.append(row)
    return result

input_example = []
output_example =[]
output = data_aggregation(input_example)


def compare(o_e, o):
    return o_e == o

print("")

# 用例目的
print("该用例目的为：测试是否正常产生压缩点")

print("")

# 子用例编号
print("子用例编号：data_aggregation_3")

print("")

print("****************************")
print("当前输入为：")
print(input_example)

print("")

print("****************************")
print("当前输出为:")
print(output)
print("")
print("****************************")
print("预设输出为:")
print(output_example)
print("")
print("****************************")
print("是否正确:")
# 输出对比结果
# 需要写一个compare函数
if compare(output_example, output):
    print("输出与预定目标相符")
else:
    print("输出与预定目标不符")
# 输出对比结果

print("\n")
